import React, { Component } from 'react';
import { Table } from '@alifd/next';
import {
    refreshAble
} from '@src/components'

import {
    requestApprovalHistory,
} from '../../../../reducer/MyProjectAction'


class ApprovalHistory extends Component {
    constructor(props) {
        super(props)
    }

    componentDidMount() {
        this.onRefresh();
    }

    componentWillUnmount() {
        this.props.fetchDataCancle();
    }

    onRefresh = () => {
        const { basicDetail } = this.props;
        this.props.fetchData(requestApprovalHistory({
            businessKey: basicDetail.data.itemApplyId
        }));
    }

    render() {
        const {data, isRefreshing} = this.props;
        //console.log('app===',this.props.basicDetail)
        return (
            <Table
                dataSource={data && data.data || []}
                hasBorder={true}
                rowSelection={{onChange: () => {}}}
                onResizeChange={this.onResizeChange}
                loading={isRefreshing}
                className="visit-record"
                >
                <Table.Column 
                    title="活动名称" 
                    dataIndex="activityName"
                />
                <Table.Column title="执行人" dataIndex="assignee"/>
                <Table.Column title="开始时间" dataIndex="startTime" />
                <Table.Column title="活动时间" dataIndex="endTime" />
                <Table.Column title="状态" dataIndex="taskLocalVariables.status" />
                <Table.Column title="意见" dataIndex="taskLocalVariables.comment" />
            </Table>
        )
    }
}

export default refreshAble('ApprovalHistory')(ApprovalHistory);